<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active {
            color: deepskyblue
        }
    </style>
</head>

<body>
    <div id="qs"></div>
    <script src="./src/react.js"></script>
    <script src="./src/react-dom.js"></script>
    <script src="./src/babel.js"></script>
    <script type="text/babel">
        function One() {
            return <div>选贤一 的conent</div>
        }

        class Tab extends React.Component {
            constructor() {
                super()
                this.state = {
                    flag: 1,
                    zujian: <One></One>
                }
            }
            changeTab = (n) => {
                this.setState({
                    flag: n
                })
                switch (n) {
                    case 1:
                        this.setState({
                            zujian: <div>选贤一 的conent</div>
                        })
                        break;
                    case 2:
                        this.setState({
                            zujian: <div>选贤二 的conent</div>
                        })
                        break;
                    case 3:
                        this.setState({
                            zujian: <div>选贤三 的conent</div>
                        })
                        break;
                    default:
                        this.setState({
                            zujian: <div>选贤一 的conent</div>
                        })
                        break;
                }
            }
            render() {
                return (
                    <div>
                        <ul>
                            <li className={this.state.flag == 1 ? 'active' : ''}
                                onClick={() => this.changeTab(1)}
                            >选项一</li>
                            <li className={this.state.flag == 2 ? 'active' : ''}
                                onClick={() => this.changeTab(2)}
                            >选项二</li>
                            <li className={this.state.flag == 3 ? 'active' : ''}
                                onClick={() => this.changeTab(3)}
                            >选项三</li>
                            
                        </ul>
                        <div>
                            {this.state.zujian}
                        </div>
                    </div>
                )
            }
        }

        ReactDOM.render(
            <Tab></Tab>,
            document.getElementById('qs')
        )
    </script>

</body>

</html>